package com.kingbi.system.function.dao;

import java.util.ArrayList;

import com.kingbi.system.function.model.FunctionModel;

public class FunctionQuery
{
    StringBuilder search_query_bud;

    StringBuilder search_count_bud;

    StringBuilder temp_bud;
    
    Object[] params ;
    
    ArrayList paramList;

    public FunctionQuery()
    {
        super();
    }

    public FunctionQuery(StringBuilder search_query_bud, StringBuilder search_count_bud,
            StringBuilder temp_bud)
    {
        super();
       
    }

    public void doSearchQuery(FunctionModel functionModel)
    {
        this.search_query_bud = new StringBuilder();
        this.search_count_bud = new StringBuilder();
        search_query_bud
                .append("from com.kingbi.system.function.model.FunctionModel function where 1=1");
        search_count_bud
                .append("select count(*) from com.kingbi.system.function.model.FunctionModel function where 1=1");
        
        temp_bud = new StringBuilder();
        paramList = new ArrayList();
       
      
        if(functionModel.getFuncCode()!=null &&  !functionModel.getFuncCode().equals("") && !functionModel.getFuncCode().equals("null")) 
        { 
                temp_bud.append(" and function.funcCode=?"); 
                 paramList.add(functionModel.getFuncCode().trim());
        } 
        if(functionModel.getName()!=null &&  !functionModel.getName().equals("") && !functionModel.getName().equals("null")) 
        { 
                temp_bud.append(" and function.name=?"); 
                 paramList.add(functionModel.getName().trim());
        } 
        if(functionModel.getDescribe()!=null &&  !functionModel.getDescribe().equals("") && !functionModel.getDescribe().equals("null")) 
        { 
                temp_bud.append(" and function.describe=?"); 
                 paramList.add(functionModel.getDescribe().trim());
        } 
        if(functionModel.getPageUrl()!=null &&  !functionModel.getPageUrl().equals("") && !functionModel.getPageUrl().equals("null")) 
        { 
                temp_bud.append(" and function.pageUrl=?"); 
                 paramList.add(functionModel.getPageUrl().trim());
        } 
        if(functionModel.getFuncLevel()!=null &&  !functionModel.getFuncLevel().equals("") && !functionModel.getFuncLevel().equals("null")) 
        { 
                temp_bud.append(" and function.funcLevel=?"); 
                 paramList.add(functionModel.getFuncLevel().trim());
        } 
        if(functionModel.getFunStatus()!=null &&  !functionModel.getFunStatus().equals("") && !functionModel.getFunStatus().equals("null")) 
        { 
                temp_bud.append(" and function.funStatus=?"); 
                 paramList.add(functionModel.getFunStatus().trim());
        } 
        if(functionModel.getFatherFunCode()!=null &&  !functionModel.getFatherFunCode().equals("") && !functionModel.getFatherFunCode().equals("null")) 
        { 
                temp_bud.append(" and function.fatherFunCode=?"); 
                 paramList.add(functionModel.getFatherFunCode().trim());
        } 


        if(paramList!=null && paramList.size()>0)
        {
            params = new Object[paramList.size()];
            for(int i=0;i<paramList.size();i++)
            {
                params[i] = paramList.get(i);
            }
        }
        
        if(temp_bud!=null && temp_bud.length()>0)
        {
            search_query_bud.append(temp_bud.toString());
            search_count_bud.append(temp_bud.toString());
        }
       
    }

    public StringBuilder getSearch_query_bud()
    {
        return search_query_bud;
    }

    public void setSearch_query_bud(StringBuilder search_query_bud)
    {
        this.search_query_bud = search_query_bud;
    }

    public StringBuilder getSearch_count_bud()
    {
        return search_count_bud;
    }

    public void setSearch_count_bud(StringBuilder search_count_bud)
    {
        this.search_count_bud = search_count_bud;
    }

    public StringBuilder getTemp_bud()
    {
        return temp_bud;
    }

    public void setTemp_bud(StringBuilder temp_bud)
    {
        this.temp_bud = temp_bud;
    }

    public Object[] getParams()
    {
        return params;
    }

    public void setParams(Object[] params)
    {
        this.params = params;
    }

    
   
}